package com.ymatou.iapi.sellerquery.testcase;

import junit.framework.Assert;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.sellerquery.parameter.GetSellerPaidSalesVolumeBean;
import com.ymatou.iapi.sellerquery.service.GetSellerPaidSalesVolumeCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;
/**
*获取商家成交额成交量接口
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetSellerPaidSalesVolume{
	private static GetSellerPaidSalesVolumeBean GetSellerPaidSalesVolumeBean;
	private static GetSellerPaidSalesVolumeCall GetSellerPaidSalesVolumeCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商家成交额成交量接口");
	}

	@Before
	public void caseUp() {
		GetSellerPaidSalesVolumeBean=new GetSellerPaidSalesVolumeBean();
		GetSellerPaidSalesVolumeCall=new GetSellerPaidSalesVolumeCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(GetSellerPaidSalesVolumeCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerPaidSalesVolume_001() {
		Logger.start(true,"获取商家成交额成交量");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));

			GetSellerPaidSalesVolumeBean.setSellerId(sellerId);
			GetSellerPaidSalesVolumeBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-5).replace(" ", "T"));
			GetSellerPaidSalesVolumeBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(2).replace(" ", "T"));
			GetSellerPaidSalesVolumeCall.setData(GetSellerPaidSalesVolumeBean);
			GetSellerPaidSalesVolumeCall.callService();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerPaidSalesVolume_002() {
		Logger.start(true,"商家id不存在");
		try {
		
			GetSellerPaidSalesVolumeBean.setSellerId(2222);
			GetSellerPaidSalesVolumeBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-5).replace(" ", "T"));
			GetSellerPaidSalesVolumeBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(2).replace(" ", "T"));
			GetSellerPaidSalesVolumeCall.setData(GetSellerPaidSalesVolumeBean);
			GetSellerPaidSalesVolumeCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS,
					GetSellerPaidSalesVolumeCall.getString("code"), "验证Code");
					
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerPaidSalesVolume_003() {
		Logger.start(true,"商家id为null");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));

			//GetSellerPaidSalesVolumeBean.setSellerId(sellerId);
			GetSellerPaidSalesVolumeBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-5).replace(" ", "T"));
			GetSellerPaidSalesVolumeBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(2).replace(" ", "T"));
			GetSellerPaidSalesVolumeCall.setData(GetSellerPaidSalesVolumeBean);
			GetSellerPaidSalesVolumeCall.callService();	
			Logger.verifyEquals(ECode.ERROR400,
					GetSellerPaidSalesVolumeCall.getString("code"), "验证Code");
			Logger.verifyEquals("100",
					GetSellerPaidSalesVolumeCall.getString("bcode"), "验证Code");
			Logger.verifyEquals("sellerId:must be greater than or equal to 1",
					GetSellerPaidSalesVolumeCall.getString("msg"), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}